package day0216;

/**
 * 先静态，再实例
 * 静态可调用静态， 实例可以调用实例也可以调用静态
 * 静态多个对象共享， 实例每个对象私有
 */
public class InstanceDemo {

    static int a = 1;

    int b;

    static {
        System.out.println("static {}");
        a = 2;
    }

    {
        System.out.println(" {} ");
        a = 3;
    }
    InstanceDemo() {
        System.out.println(" InstanceDemo() ");
        a = 4;
    }

    InstanceDemo(int n){
        System.out.println("InstanceDemo(int n)");
        b = n;
    }

    public static void main(String[] args) {
        InstanceDemo instanceDemo1 = new InstanceDemo(6);
        InstanceDemo instanceDemo = new InstanceDemo();

        System.out.println(instanceDemo.a);
        System.out.println(instanceDemo1.a);
        System.out.println(instanceDemo.b);
        System.out.println(instanceDemo1.b);

    }




}
